package com.icinfo.cloud.provider.punish.ucase.casemain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：管辖依据枚举
 *
 * @author xiangyuyu
 * @date 2022-04-09 14:21
 */
@AllArgsConstructor
public enum JurisdictionBasisEnum {
    /**
     * 管辖依据枚举
     */
    J_15_060052_1("15_060052-1", "被申请人住所地"),
    J_15_060052_2("15_060052-2", "被申请人居住地"),
    J_15_060052_3("15_060052-3", "被申请人经常居住地"),
    J_15_060052_4("15_060052-4", "被申请人财产所在地"),
    J_15_060052_5("15_060052-5", "被申请人不动产所在地"),
    J_15_060052_6("15_060052-6", "被申请人原户籍所在地"),
    J_15_060052_7("15_060052-7", "被申请人在国内最后居住地"),
    J_15_060052_8("15_060052-8", "被申请人所在单位驻地"),
    J_15_060052_9("15_060052-9", "被申请人被监禁地"),
    J_15_060052_10("15_060052-10", "被申请人被劳动教养地"),
    J_15_060052_11("15_060052-11", "被申请人注册登记地"),
    J_15_060052_12("15_060052-12", "被申请人主要营业地"),
    J_15_060052_13("15_060052-13", "被申请人主要办事机构所在地"),
    J_15_060052_14("15_060052-14", "被申请人代表机构住所地"),
    J_15_060052_15("15_060052-15", "指定管辖"),
    J_15_060052_255("15_060052-255", "其他");


    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;

    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author xiangyuyu
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (JurisdictionBasisEnum e : JurisdictionBasisEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return code;
    }

    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author xiangyuyu
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (JurisdictionBasisEnum e : JurisdictionBasisEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
